Public Class HotlineChangerSingleReport
    Inherits [lib].BasePage

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
    Protected WithEvents ContentPaneFooter1 As ccapps.BillingNetControlLibrary.ContentPaneFooter

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private _PointingLinks() As String = New String() {"HotlineChangerSingleReport.aspx?CachingPreventionParameter=" & DateTime.Now.ToString("yyyyMMddHHmmss"), "HotlineChangerSingleReport.aspx?CachingPreventionParameter=" & DateTime.Now.ToString("yyyyMMddHHmmss")}
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.PageTitle = "Hotline Changer (Single) Report"

        If (Not Me.IsPostBack) Then
            listHistory(0)
        End If

    End Sub

    Private Sub DataGrid1_PageIndexChanged(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
        Me.listHistory(e.NewPageIndex)
    End Sub

    Private Sub listHistory(ByVal pageIndex As Integer)
        Me.DataGrid1.CurrentPageIndex = pageIndex
        Me.DataGrid1.VirtualItemCount = persistent.Hotline.GetItemCountForProcessType(persistent.Hotline.HotlineChangeProcessType.SINGLE)
        Me.DataGrid1.DataSource = persistent.Hotline.GetHotlineProcessHistory(persistent.Hotline.HotlineChangeProcessType.SINGLE, Session("user"), Me.DataGrid1.CurrentPageIndex, Me.DataGrid1.PageSize)
        Me.DataGrid1.DataBind()
    End Sub

    Private Sub ContentPaneFooter1_Confirmed(ByVal sender As Object, ByVal e As System.EventArgs) Handles ContentPaneFooter1.Confirmed
        Dim currentPageIndex = Me.DataGrid1.CurrentPageIndex
        Me.DataGrid1.AllowPaging = False
        listHistory(0)

        Response.Cache.SetCacheability(HttpCacheability.NoCache)

        Response.ContentType = "application/vnd.ms-excel"

        Response.Charset = ""

        Me.EnableViewState = False

        Dim stringWrite As New System.IO.StringWriter

        Dim htmlWrite As New HtmlTextWriter(stringWrite)

        Me.DataGrid1.RenderControl(htmlWrite)

        Response.Write(stringWrite.ToString())

        Response.End()
        Me.DataGrid1.AllowPaging = True
        listHistory(currentPageIndex)
    End Sub
End Class
